package com.yunlankeji.stemcells.activity.home;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yunlankeji.ganxibaozhijia.R;
import com.yunlankeji.stemcells.activity.mine.Address_editActivity;
import com.yunlankeji.stemcells.activity.mine.mine_addressActivity;
import com.yunlankeji.stemcells.adapter.AddressAdapter;
import com.yunlankeji.stemcells.adapter.Expert_databaseAdapter;
import com.yunlankeji.stemcells.model.request.Address;
import com.yunlankeji.stemcells.model.request.Expert_database;

import java.util.ArrayList;
import java.util.List;

public class Home_expert_databaseActivity extends AppCompatActivity {
    TextView tv_expert_name,tv_expert_position,tv_expert_title,tv_search;
    LinearLayout lt_expert_return,item_lt_expert;
    ImageView iv_expert_picture;
    RecyclerView rv_expert_database;
    TextView tv_stem_cells,tv_genetic,tv_the_tumor,tv_blood,tv_biological_molecules;
    LinearLayout lt_stem_cells,lt_genetic,lt_the_tumor,lt_blood,lt_biological_molecules;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home_expert_database);

        tv_expert_name=findViewById(R.id.tv_expert_name);
        tv_expert_position=findViewById(R.id.tv_expert_position);
        tv_expert_title=findViewById(R.id.tv_expert_title);
        tv_search=findViewById(R.id.tv_expert_database_search);
        lt_expert_return=findViewById(R.id.lt_home_expert_database_return);
        item_lt_expert=findViewById(R.id.item_lt_expert_database);
        iv_expert_picture=findViewById(R.id.iv_expert_picture);
        rv_expert_database=findViewById(R.id.rv_expert_database);
        tv_stem_cells = findViewById(R.id.tv_stem_cells);
        tv_genetic = findViewById(R.id.tv_genetic);
        tv_the_tumor = findViewById(R.id.tv_the_tumor);
        tv_blood = findViewById(R.id.tv_blood);
        tv_biological_molecules = findViewById(R.id.tv_biological_molecules);
        lt_stem_cells = findViewById(R.id.lt_stem_cells);
        lt_genetic = findViewById(R.id.lt_genetic);
        lt_the_tumor = findViewById(R.id.lt_the_tumor);
        lt_blood = findViewById(R.id.lt_blood);
        lt_biological_molecules = findViewById(R.id.lt_biological_molecules);
        lt_stem_cells.setOnClickListener(new Mytest());
        lt_genetic.setOnClickListener(new Mytest());
        lt_the_tumor.setOnClickListener(new Mytest());
        lt_blood.setOnClickListener(new Mytest());
        lt_biological_molecules.setOnClickListener(new Mytest());

        lt_expert_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });


        List<Expert_database> expert_databasesList = new ArrayList<>();
        Expert_database expert_database1 = new Expert_database("123","123","生物化学及分子生物学博士， 中国医药学专家，专治各种疑难杂症",R.mipmap.icon_expert);
        Expert_database expert_database2 = new Expert_database("123","123","生物化学及分子生物学博士， 中国医药学专家，专治各种疑难杂症",R.mipmap.icon_expert);
        Expert_database expert_database3 = new Expert_database("123","123","生物化学及分子生物学博士， 中国医药学专家，专治各种疑难杂症",R.mipmap.icon_expert);
        Expert_database expert_database4 = new Expert_database("123","123","生物化学及分子生物学博士， 中国医药学专家，专治各种疑难杂症",R.mipmap.icon_expert);

        expert_databasesList.add(expert_database1);
        expert_databasesList.add(expert_database2);
        expert_databasesList.add(expert_database3);
        expert_databasesList.add(expert_database4);
        GridLayoutManager gridLayoutManager=new GridLayoutManager(Home_expert_databaseActivity.this,3);
        rv_expert_database.setLayoutManager(gridLayoutManager);
        Expert_databaseAdapter expert_databaseAdapter= new Expert_databaseAdapter(expert_databasesList);


        rv_expert_database.setAdapter(expert_databaseAdapter);

        // 设置item及item中控件的点击事件
        expert_databaseAdapter.setOnItemClickListener(new Expert_databaseAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View v, Expert_databaseAdapter.ViewName viewName, int position) {
                switch (v.getId()){

                    case R.id.item_lt_expert_database:
                        startActivity(new Intent(Home_expert_databaseActivity.this, Address_editActivity.class));
                        break;
                }

            }

            @Override
            public void onItemLongClick(View v) {

            }
        });

    }

    private class Mytest implements View.OnClickListener {
        @Override
        public void onClick(View v) {

            Intent intent = new Intent();
            switch (v.getId()){

                case R.id.lt_stem_cells:
                    String cells=tv_stem_cells.getText().toString();
                    intent.putExtra("title",cells);
                    intent.setClass(Home_expert_databaseActivity.this,Home_expert_classifyActivity.class);
                    startActivity(intent);
                    break;
                case R.id.lt_genetic:
                    String genetic=tv_genetic.getText().toString();
                    intent.putExtra("title",genetic);
                    intent.setClass(Home_expert_databaseActivity.this,Home_expert_classifyActivity.class);
                    startActivity(intent);
                    break;
                case R.id.lt_the_tumor:
                    String tumor=tv_the_tumor.getText().toString();
                    intent.putExtra("title",tumor);
                    intent.setClass(Home_expert_databaseActivity.this,Home_expert_classifyActivity.class);
                    startActivity(intent);
                    break;
                case R.id.lt_blood:
                    String blood=tv_blood.getText().toString();
                    intent.putExtra("title",blood);
                    intent.setClass(Home_expert_databaseActivity.this,Home_expert_classifyActivity.class);
                    startActivity(intent);
                    break;
                case R.id.lt_biological_molecules:
                    String molecules=tv_biological_molecules.getText().toString();
                    intent.putExtra("title",molecules);
                    intent.setClass(Home_expert_databaseActivity.this,Home_expert_classifyActivity.class);
                    startActivity(intent);
                    break;
            }


        }
    }
}